package xm.contact.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xm.contact.Pojo.Contact;
import xm.contact.Service.ContactService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/liuyan")
@CrossOrigin
public class ContactController {
    @Autowired
    ContactService contactService;

    @GetMapping("/showall")
    public Map<String,Object> showall(String cname,int page,int limit){
        Map<String,Object> map=new HashMap<>();
        List<Contact> list=contactService.showall(cname,page,limit);
        map.put("data",list);
        map.put("code",0);
        map.put("count",contactService.getCount(cname));
        map.put("cname",cname);
        return map;
    }
    @PostMapping("/add")
    public int add(Contact contact){
        System.out.println("aaaa");
        System.out.println("aaaa");
        System.out.println("aaaa");
        System.out.println("aaaa");
        System.out.println("aaaa");

        return contactService.add(contact);
}

}
